package com.zking.myservlet.order;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/manage/OrderModify")
public class OrderModify extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        resp.setCharacterEncoding("UTF-8");

        int id = Integer.parseInt(req.getParameter("orderId"));
        String username = req.getParameter("userName");
        String address = req.getParameter("address");
        double cost = Double.parseDouble(req.getParameter("cost"));
        String date = req.getParameter("date");
        int status = Integer.parseInt(req.getParameter("status"));

        req.setAttribute("orderId", id);
        req.setAttribute("userName", username);
        req.setAttribute("address", address);
        req.setAttribute("cost", cost);
        req.setAttribute("date", date);
        req.setAttribute("status", status);

        req.getRequestDispatcher("order-modify.jsp").forward(req, resp);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
